package com.sdb.mainDiagnosis.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sdb.common.annotation.Log;
import com.sdb.common.core.controller.BaseController;
import com.sdb.common.core.domain.AjaxResult;
import com.sdb.common.enums.BusinessType;
import com.sdb.mainDiagnosis.domain.TdMainDiagnosis;
import com.sdb.mainDiagnosis.service.ITdMainDiagnosisService;
import com.sdb.common.utils.poi.ExcelUtil;
import com.sdb.common.core.page.TableDataInfo;

/**
 * 主要诊断Controller
 * 
 * @author yyh
 * @date 2025-02-05
 */
@RestController
@RequestMapping("/mainDiagnosis/diagnosis")
public class TdMainDiagnosisController extends BaseController
{
    @Autowired
    private ITdMainDiagnosisService tdMainDiagnosisService;

    /**
     * 查询主要诊断列表
     */
    @PreAuthorize("@ss.hasPermi('index')")
    @GetMapping("/list")
    public TableDataInfo list(String keyword)
    {
//        startPage();
        List<TdMainDiagnosis> list = tdMainDiagnosisService.selectTdMainDiagnosisList(keyword);
        return getDataTable(list);
    }

    /**
     * 导出主要诊断列表
     */
//    @PreAuthorize("@ss.hasPermi('mainDiagnosis:diagnosis:export')")
//    @Log(title = "主要诊断", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, TdMainDiagnosis tdMainDiagnosis)
//    {
//        List<TdMainDiagnosis> list = tdMainDiagnosisService.selectTdMainDiagnosisList(tdMainDiagnosis);
//        ExcelUtil<TdMainDiagnosis> util = new ExcelUtil<TdMainDiagnosis>(TdMainDiagnosis.class);
//        util.exportExcel(response, list, "主要诊断数据");
//    }

    /**
     * 获取主要诊断详细信息
     */
    @PreAuthorize("@ss.hasPermi('index')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tdMainDiagnosisService.selectTdMainDiagnosisById(id));
    }

    /**
     * 新增主要诊断
     */
    @PreAuthorize("@ss.hasPermi('index')")
    @Log(title = "主要诊断", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdMainDiagnosis tdMainDiagnosis)
    {
        return toAjax(tdMainDiagnosisService.insertTdMainDiagnosis(tdMainDiagnosis));
    }

    /**
     * 修改主要诊断
     */
    @PreAuthorize("@ss.hasPermi('index')")
    @Log(title = "主要诊断", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdMainDiagnosis tdMainDiagnosis)
    {
        return toAjax(tdMainDiagnosisService.updateTdMainDiagnosis(tdMainDiagnosis));
    }

    /**
     * 删除主要诊断
     */
    @PreAuthorize("@ss.hasPermi('index')")
    @Log(title = "主要诊断", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdMainDiagnosisService.deleteTdMainDiagnosisByIds(ids));
    }
}
